package com.gitee.jisong.superlogger.ctrl

import com.gitee.jisong.spring.annotation.GETPOST
import com.gitee.jisong.superlogger.pojo.Applications
import com.gitee.jisong.superlogger.dao.ApplicationsDAO
import com.gitee.jisong.superlogger.service.ApplicationsServ
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import java.time.LocalDateTime


@RestController
@RequestMapping("/super-logger/application")
open class ApplicationsCtrl {
    private val logger:Logger = LoggerFactory.getLogger(ApplicationsCtrl::class.java)
    @Autowired
    lateinit var applicationsServ: ApplicationsServ

    @Autowired
    lateinit var applicationsDAO: ApplicationsDAO


    @GETPOST("/list")
    fun list():List<Applications>{
        val applications = Applications()
        applications.createTime = LocalDateTime.now()
        logger.info("{}",applications)
        applicationsDAO.insert(applications)
        return applicationsDAO.queryAll()
    }


    @PostMapping("/save")
    fun insert(applications: Applications) {
        applications.valid_insert()

    }
}